package com.example.yuejianapp14.Activity.Adapter;

import android.app.Instrumentation;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.Objects;

/**
 * Created by 张森 on 2017/11/2.
 */

public class Lunboadapter extends PagerAdapter {
      private ArrayList<Integer> viewlist;
    private Context context;
        public Lunboadapter(Context context, ArrayList<Integer> viewlist)
        {
            this.context=context;
            this.viewlist=viewlist;
        }





    @Override
    public int getCount() {
        return viewlist.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        Log.e("img",viewlist.size()+"");
        ImageView img =new ImageView(context);
        img.setBackgroundResource(viewlist.get(position));
        container.addView(img);
        return img;
    }


    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}
